// 定义成一个模块
define(["template","jquery","header"], (tmp) => {
  class Land {
    constructor() {
      this.loadHTML();
      this.prodList = [];
    }

    loadHTML() {
      // 使用jquery的方法去加载header.html
      $(".koukou").load("/html/modules/land.html", () => {
        $("#ddl_zc").click(function () {
          $(".koukou").css("display", "block");
        });
        $("#guanbii").click(function () {
          $(".koukou").css("display", "none");
        });
        this.ddLu();
      });
    }
    // 用户登陆
    ddLu() {
      // 获取元素
      const btn = document.querySelector(".btn"),
        inps = document.querySelectorAll(".chuangkou input");
        const that = this
      btn.onclick = function () {
        // 点击按钮获取value的值
        // 把获取的值存到localStorage
        // 然后取数据渲染页面
        const username = inps[0].value,
          password = inps[1].value;



        if (username === "" && password === "") {
          alert("请输入用户名和密码");
        } else {
          const pord = [{ username, password }];
          localStorage.setItem("username", JSON.stringify(pord));
          const prodList = localStorage.getItem("username");
          if (prodList && prodList != "[]") {
            that.prodList = JSON.parse(prodList);
            const obj = that.prodList[0]
            that.render(obj)
            // 渲染页面

          }
          $(".koukou").css("display", "none");

        }
      };
    }
    // 渲染用户信息
    render(obj){
      alert('登陆成功')
      $("#ddl_zc").html(obj.username);
    }

  }
  return new Land();
});
